@extends("admin.common.admin")
<title>好客租房-个人信息</title>
@section("cnt")
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i>
        首页
        <span class="c-gray en">&gt;</span>
        个人信息管理
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <div class="page-container">
        @include("admin.common.msg")
        <div class="mt-20">
            <table class="table table-border table-bordered table-hover table-bg table-sort">
                <thead>
                <tr class="text-c">
                    <th width="25"><input type="checkbox" name="" value=""></th>
                    <th width="80">ID</th>
                    <th width="100">用户名</th>
                    <th width="100">真实姓名</th>
                    <th width="40">性别</th>
                    <th width="90">手机</th>
                    <th width="150">邮箱</th>
                    <th width="">IP地址</th>
                    <th width="130">加入时间</th>
                    <th width="70">状态</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                <tbody>
                    <tr class="text-c">
                        <td><input type="checkbox" value="{{ $data["id"] }}" name="id[]"></td>
                        <td>{{ $data["id"] }}</td>
                        <td>{{ $data["username"] }}</td>
                        <td>{{ $data["truename"] }}</td>
                        <td>{{ $data["sex"] }}</td>
                        <td>{{ $data["phone"] }}</td>
                        <td>{{ $data["email"] }}</td>
                        <td class="text-l">{{ $data["last_ip"] }}</td>
                        <td>{{ $data->created_at }}</td>
                        <td class="td-status">
                            @if(!$data->deleted_at)
                                <span class="label label-success radius">已启用</span>
                            @else
                                <span class="label label-danger radius">禁用</span>
                            @endif
                        </td>
                        <td class="td-manage">
                            <a href="{{ route("admin.edits",["id" => $data->id]) }}" class="label label-primary">
                                修改
                            </a>
                            <a href="{{ route("admin.index") }}" class="label label-primary">
                                返回页面
                            </a>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
@endsection
@section("js")
    <script>
        function datadel() {
            // 定义一个空的变量
            let id = [];
            // 获取到id
            let inplist = $("input[name='id[]']:checked");
            // console.log(inp)
            if(inplist.length>0){
                $.each(inplist,(key,item)=>{
                    id.push(Number($(item).val()));
                })
                if(id.length>0){
                    layer.confirm('确认删除该页面的全部用户吗？', {
                        btn: ['确认','取消'] //按钮
                    }, ()=> {
                        $.get("{{ route("admin.admin.deleteAll") }}",{id}).then(ret => {
                            layer.msg(ret.msg, {icon: 1,time: 2000},()=>{
                                if(ret.status == 200){
                                    location.reload();
                                }

                            });
                        })
                    });
                }
            }
        };
        $(function () {
            $(".del").click(function () {
                // let href = ;
                layer.confirm('确认删除该用户吗？', {
                    btn: ['确认','取消'] //按钮
                }, ()=>{
                    $.ajax({
                        url : $(this).attr("href"),
                        type : "delete",
                        data :{
                            _token:"{{ csrf_token() }}"
                        }
                    }).then(ret => {
                        // console.log(ret);
                        layer.msg(ret.msg, {icon: 1,time: 2000},()=>{
                            if(ret.status == 200){
                                $(this).parents("tr").remove();
                            }

                        });
                    });

                });


                return false;
            });
        })

    </script>
@endsection
